package com.sky.task;

import lombok.extern.slf4j.Slf4j;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 定时任务
 * @author admin
 * @date 2024/10/7
 */
@Slf4j
// @Component
public class MyTask {
    @Scheduled(cron = "0/5 * * * * ?")
    public void printHello() {
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

        log.info("定时任务执行了... hello" + dtf.format(LocalDateTime.now()));
    }
}
